using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using DevExpress.ExpressApp.Win.Editors;
using DevExpress.ExpressApp.Model;

namespace TestPermission.Module.Win
{
    public partial class MembersAccessPermissionController : ViewController
    {
        public MembersAccessPermissionController()
        {
            InitializeComponent();
            RegisterActions(components);
            TargetViewType = ViewType.DetailView;
            TargetObjectType = typeof(MemberAccessPermission);
        }

        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();

            (View as DetailView).GetItems<TypePropertyEditor>()[0].CurrentObjectChanged += new EventHandler<EventArgs>(MembersAccessPermissionController_CurrentObjectChanged);
            //MemberAccessPermission s=View.CurrentObject as MemberAccessPermission;

            //IList<> editors = ((DetailView)View).GetItems<LookupEdit>();
            //foreach (LookupEdit editor in editors)
            //{

            //    if (editor.PropertyName == "MemberName")
            //    {
            //        //editor.o
            //    }
            //    //editor.e.PreRender += new EventHandler(Editor_PreRender);
            //    //editor.
            //}

        }

        void MembersAccessPermissionController_CurrentObjectChanged(object sender, EventArgs e)
        {
            View.Model.GetNode<IModelViewItems>("Items")
               .GetNode<IModelPropertyEditor>("MemberName")
               .PredefinedValues = "wwww" + DateTime.Now; //GetPredefinedValues();
        }
        //        private string GetPredefinedValues()
        //        {
        //StringBuilder sb=new StringBuilder();
        //  if ( != null)
        //  {    }
        //      PropertyInfo[] properties = ObjectType.GetProperties(BindingFlags.Public|BindingFlags.Instance|BindingFlags.DeclaredOnly);}
        //      foreach (var item in properties)
        //      {
        //          //[item.GetCustomAttributes(typeof(BrowsableAttribute),true)]
        //          ObjectProperty _property = new ObjectProperty(item.Name);
        //          list.Add(_property);
        //      }
        //  }
        //  return list;
    }
}